//
//  SecondCell.m
//  ProjectA
//
//  Created by lanouhn on 15/5/26.
//  Copyright (c) 2015年 lanouhn. All rights reserved.
//

#import "SecondCell.h"
#import "UIImageView+WebCache.h"
#define padding 10



@interface SecondCell ()
@property (nonatomic ,retain)UIImageView *viewOfImage;
@property (nonatomic ,retain)UILabel *title;
@property (nonatomic ,retain)UILabel *arraySubtitle;

@end
@implementation SecondCell
- (void)dealloc{
    [_title release];
    [_arraySubtitle release];
    [_viewOfImage release];
    [super dealloc];
}
- (UIImageView *)viewOfImage{
    if (!_viewOfImage) {
        self.viewOfImage = [[[UIImageView alloc]initWithFrame:CGRectMake(padding/2, padding / 2, 60, 60)]autorelease];
        [self.contentView addSubview:_viewOfImage];
    }
    return _viewOfImage;
}
- (UILabel *)title {
    if (!_title) {
        self.title = [[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.viewOfImage.frame) + padding / 2, padding * 2, 190, 30)]autorelease];
        _title.font = [UIFont systemFontOfSize:18];
        [self.contentView addSubview:_title];
    }
    return _title;
}
- (UILabel *)arraySubtitle {
    if (!_arraySubtitle) {
        self.arraySubtitle = [[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.title.frame) - padding *1.5, padding * 2, 150, 30)]autorelease];
        _arraySubtitle.font = [UIFont systemFontOfSize:16];
        _arraySubtitle.textColor = [UIColor grayColor];
        [self.contentView addSubview:_arraySubtitle];
    }
    return _arraySubtitle;
}
- (void)cellWithModel:(SecondModel *)model{
    [self.viewOfImage sd_setImageWithURL:[NSURL URLWithString:model.imgUrl]];
    self.title.text = model.title;
    NSArray *array = model.cats;
    NSString *subtitle = [array componentsJoinedByString:@","];
    self.arraySubtitle.text = subtitle;
     
}

@end
